package com.leetcode;


import org.junit.jupiter.api.Test;

public class LeetCodeLC01 {
    private int start = 0;
    private int tail = 0;
    private int capacity = 3;
    private Integer[] queue = null;

    public LeetCodeLC01() {
        this.queue = new Integer[3];
        this.capacity = 3;
    }


    public boolean enQueue(int value) {
        if (tail < capacity) {
            queue[tail] = value;
            tail++;
        } else {
            return false;
        }
        return true;
    }

    public boolean deQueue(){
        queue[start] = null;
        tail = 0;
        start++;
        return true;
    };

    public int Front(){
        if (isEmpty()){
            return -1;
        }

        return queue[start];
    }

    public int Rear(){
        if (isEmpty()){
            return -1;
        }
        return queue[start];
    }

    public boolean isFull(){
        if (tail == capacity){
            return true;
        }
        return false;
    }

    public boolean isEmpty(){
        if (start == capacity){
            return true;
        }
        return false;
    }

    @Test
    public void test(){
        LeetCodeLC01 solutionLC01 = new LeetCodeLC01();
        solutionLC01.enQueue(1);
        solutionLC01.enQueue(2);
        solutionLC01.enQueue(3);
        solutionLC01.isFull();
        solutionLC01.deQueue();
        solutionLC01.deQueue();
        solutionLC01.deQueue();
        solutionLC01.enQueue(4);
        solutionLC01.enQueue(5);
        solutionLC01.enQueue(5);
        solutionLC01.enQueue(5);
    }
}
